import osmnx
import folium
import networkx
import statistics
graph = osmnx.graph_from_place("Yoyogi Park, Shibuya, Tokyo, Japan")
osmnx.save_graphml(graph, "yoyogi_park_graph.graphml")
graph = osmnx.load_graphml("yoyogi_park_graph.graphml")
type(graph)
networkx.classes.multidigraph.MultiDiGraph
osmnx.plot_graph(graph)
(<Figure size 576x576 with 1 Axes>, <AxesSubplot:>)
len(graph.nodes)
len(graph.edges)
graph.nodes[1520546819]
graph.edges[(1520546819, 3010293622, 0)]
{'osmid': 138670840,
'highway': 'footway',
'oneway': False,
'length': 59.113,
'geometry': <shapely.geometry.linestring.LineString at 0x7ffc5f0ad4c0>}
len(graph.edges)
287
graph.nodes[1520546819]
{'y': 35.6711267, 'x': 139.6925951, 'street_count': 4}
graph.edges[(1520546819, 3010293622, 0)]
{'osmid': 138670840,
'highway': 'footway',
'oneway': False,
'length': 59.113,
'geometry': <shapely.geometry.linestring.LineString at 0x7ffc5f0ad4c0>}
deventer_graph = osmnx.graph_from_place("Deventer, Netherlands", network_type="drive")
osmnx.save_graphml(deventer_graph, "deventer_graph.graphml")
deventer_graph = osmnx.load_graphml("deventer_graph.graphml")
osmnx.plot_graph(deventer_graph, figsize=(21, 21))
(<Figure size 1512x1512 with 1 Axes>, <AxesSubplot:>)
m = folium.Map(location=[52.248061, 6.244875], zoom_start=12)
m
osmnx.folium.plot_graph_folium(deventer_graph, popup_attribute='name', tiles="cartodbpositron", weight=2)